/*
 * @Author: 江舟 jijiangzhou@recycloud.cn
 * @Date: 2024-04-19 09:26:15
 * @LastEditors: 江舟 jijiangzhou@recycloud.cn
 * @LastEditTime: 2024-05-17 11:41:55
 * @FilePath: \vite-project\src\components\common\PageBread.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import useUserStore from 'store/user';
import { Breadcrumb } from 'antd';
import { useMatches } from 'react-router-dom';

const PageBread = () => {
    const { menuMap } = useUserStore();
    const matches = useMatches();
    const breadItems = matches?.map((item) => {
        let orginPath = item.pathname;
        if (Object.keys(item?.params || {})?.length) {
            for (let k in item?.params) {
                if (item?.params?.[k]) {
                    orginPath = orginPath.replace(item.params[k], `:${k}`);
                }
            }
        }
        return {
            title: menuMap?.[orginPath]?.label,
        };
    });
    return <Breadcrumb className='mt-12px px-12px' items={breadItems} />;
};

export default PageBread;
